package question2;

import java.io.File;
import java.util.HashMap;

public class Test2 {
        public static void main(String[] args) {

            File file = new File("Day_10");
            HashMap<String, Integer> hm = new HashMap<String, Integer>();
            getCount(hm,file);
            System.out.println(hm);
        }

        private static void getCount(HashMap<String, Integer> hm, File file)  {
           if (file!=null){
               File[] files = file.listFiles();
               if (files!=null){
               for (File file1 : files) {
                   if (file1.isFile()){
                       String[] split = file1.getName().split("\\.");
                       if (split.length==2){
                           if (hm.containsKey(split[1])){
                               int count1=hm.get(split[1]);
                               count1++;
                               hm.put(split[1],count1);
                           }else{
                               hm.put(split[1],1);
                           }
                       }
                   }
                   else{
                       getCount(hm,file1);
                   }
               }
           }
           }
           else System.out.println("文件夹不存在");
        }
    }